gpt-4-0314· openai
Suzhen/CodeChat
fivem scripting How can I make it so if side is equal to A then the player id A get…
- User
fivem scripting How can I make it so if side is equal to A then the player id A get message you you win and player B get message you lose local teams = {['A']= playerid, ['B']= playerid} local side = 'A' for k,v in pairs(teams) do TriggerClientEvent('main-volleyball:client:drawtext', v, side) end
- Assistant
You can add a conditional statement inside the loop to check if the side is equal to the key of the table. If it is, then you'll send the "you win" message to that player, and the "you lose" message to the other player.
Here's an example of how that would look:
local teams = {['A'] = playerid_A, ['B'] = playerid_B} local side = 'A' for k, playerid in pairs(teams) do if k == side then -- Side A wins. TriggerClientEvent('main-volleyball:client:drawtext', playerid, "You win") else -- Side B loses. TriggerClientEvent('main-volleyball:client:drawtext', playerid, "You lose") end endThis code will loop through the
teamstable and send the appropriate win/lose messages to each player based on the value ofside.