Raised This Month: $12 Target: $400
 3% 

[HELP] Answer of Client!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 12-04-2018 , 17:12   [HELP] Answer of Client!
Reply With Quote #1

Hello guys,

For fun and to improve my SourcePawn skills I decided to do a simple thing... a Question with an answer!
So i am doing a Question that if client answers correctly it gives 1000 credits to client but if not correct i want to it say that it's not correct and to end the question time!

Here's the code
PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "SpirT"
#define ChatTag "{blue}[MATH QUIZ BY SPIRT]"

#include <sourcemod>
#include <sdktools>
#include <store>
#include <spirt_colors>

public Plugin myinfo =
{
    
name "MathQuiz by SpirT",
    
author PLUGIN_AUTHOR,
    
version "1.0.0",
    
description "MathQuiz made by SpirT get credits if you answer correctly",
    
url ""
};

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
}

public 
Action Event_RoundStart(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int client;
    
char cname[128];
    
GetClientName(clientcnamesizeof(cname));
    
char answer4[32];
    
char clientanswer[120];
    
char creditsanswer[32];
    
char correctanswer[32];
    
correctanswer "5000";
    
answer4 "5000";
    
creditsanswer "1000";
    
PrintToChatAll("%s {red} 2 x 2500 = ?? >> 1000 credits <<"ChatTag);
    if (
clientPrintToChat(clientcorrectanswer))
    {
        
Store_SetClientCredits(client1000);
        
PrintToChatAll("%s {purple}%s {red}You got {green}%s"ChatTagcnamecreditsanswer);
    }
    if (
PrintToChatAll(clientanswer 5000)) /* line 45 */
    
{
        
PrintToChat(client"%s {red}Sorry not correct"ChatTag);
    }
    if (
PrintToChatAll(clientanswer "5000")) /* line 49 */
    
{
        
PrintToChat(client"%s {red}Sorry not correct"ChatTag);
    }

Errors
Code:
error 033: array must be indexed (variable "clientanswer") -> line 45

error 033: array must be indexed (variable "clientanswer") -> line 49
__________________
SpirT is offline
Vaggelis
Senior Member
Join Date: May 2017
Old 12-04-2018 , 17:40   Re: [HELP] Answer of Client!
Reply With Quote #2

The whole thinking is wrong. You have to many variables for no reason, also u can't just create a variable named client and be an actual client. Instead of using GetClientName u can just print the name with this: %N.
ex:
PHP Code:
PrintToChatAll("%N got 1000 credits"client
This:
PHP Code:
if (clientPrintToChat(clientcorrectanswer))
    {
        
Store_SetClientCredits(client1000);
        
PrintToChatAll("%s {purple}%s {red}You got {green}%s"ChatTagcnamecreditsanswer);
    }
    if (
PrintToChatAll(clientanswer 5000)) /* line 45 */
    
{
        
PrintToChat(client"%s {red}Sorry not correct"ChatTag);
    }
    if (
PrintToChatAll(clientanswer "5000")) /* line 49 */
    
{
        
PrintToChat(client"%s {red}Sorry not correct"ChatTag);
    } 
It should be like this:
PHP Code:
if(clientanswer == 5000)
{
    
PrintToChat(client"Correct")
    
Store_SetClientCredits(clientStore_GetClientCredits 1000)
}
else
{
    
PrintToChat(client"Wrong")

Anyway, there a lot of things that need to be fixed
Vaggelis is offline
Cruze
Veteran Member
Join Date: May 2017
Old 12-05-2018 , 02:09   Re: [HELP] Answer of Client!
Reply With Quote #3

You can take help from here:
https://forums.alliedmods.net/showpo...&postcount=538
__________________
Taking paid private requests! Contact me
Cruze is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode